package cn.com.codingce.student.servlet;

import cn.com.codingce.student.entity.Login;
import cn.com.codingce.student.service.ITeacherService;
import cn.com.codingce.student.service.impl.TeacherServiceImpl;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class QueryTeacherServlet
 */
@WebServlet("/QueryTeacherServlet")
public class QueryTeacherServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int no = Integer.parseInt(request.getParameter("id"));
		ITeacherService iteaservice = new TeacherServiceImpl();
		Login teacher = iteaservice.queryLoginById(no);

		
		/*
		 * 将查询到的学生放入request域
		 */
		request.setAttribute("teacher", teacher);
		
		request.getRequestDispatcher("teaInfo.jsp").forward(request, response);
	}

}
